# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=aws-c-compression
pkgver=0.3.0
pkgrel=0
pkgdesc="C99 implementation of huffman encoding/decoding"
url="https://github.com/awslabs/aws-c-compression"
# s390x: aws-c-common
arch="all !s390x"
license="Apache-2.0"
makedepends="
	aws-c-common-dev
	cmake
	samurai
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-c-compression/archive/refs/tags/v$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$crossopts
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev
	amove usr/lib/aws-c-compression
}

sha512sums="
aae2031c22a5d716eb5be274eba7c49a4f4fb322b42d3709a7bf5cd64188b26a0938ef9b0b8e21f4e0cb8d236b4903605a78ddb76221a255d46ac57c5164402c  aws-c-compression-0.3.0.tar.gz
"
